package converter

import converter.util.EffectivePomProducer;
import converter.util.EnvRetriver;
import converter.util.PomFinder;

class Main {

	static void main(args) {
		def dir = /C:\work\Dnbi\proj-fe\svn\RT110NA3\livexp-platform\livexp-core/
		EnvRetriver er = new EnvRetriver()
		PomFinder pf = new PomFinder()
		ProjectRender pr = new ProjectRender()
		EffectivePomProducer epp = new EffectivePomProducer(er.getEnvMap())
		List allPoms = pf.findAllPoms(new File(dir))
		allPoms.each{ File pomFile ->
			println "Pom: " + pomFile.absolutePath
			File effectivePom = epp.getEffectivePom(pomFile)
			File ouputGradleBuild = new File(pomFile.parentFile,"build.gradle")
			if(ouputGradleBuild.exists()) {
				ouputGradleBuild.delete()
			}
			ouputGradleBuild << pr.renderProject(effectivePom)
			println "Created file " + ouputGradleBuild.absolutePath
		}
	}
}
